home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / progs / sviluppo / python-1.4 / lib / test / test_support.py < prev    next >
Text File  |  1996-11-24  |  869b  |  42 lines

  1. # Python test set -- supporting definitions.
  2.  
  3. TestFailed = 'test_support -- test failed'    # Exception
  4.  
  5. def unload(name):
  6.     import sys
  7.     try:
  8.         del sys.modules[name]
  9.     except KeyError:
  10.         pass
  11.  
  12. def forget(modname):
  13.     unload(modname)
  14.     import sys, os
  15.     for dirname in sys.path:
  16.         try:
  17.             os.unlink(os.path.join(dirname, modname + '.pyc'))
  18.         except os.error:
  19.             pass
  20.  
  21. FUZZ = 1e-6
  22.  
  23. def fcmp(x, y): # fuzzy comparison function
  24.     if type(x) == type(0.0) or type(y) == type(0.0):
  25.         try:
  26.             x, y = coerce(x, y)
  27.             fuzz = (abs(x) + abs(y)) * FUZZ
  28.             if abs(x-y) <= fuzz:
  29.                 return 0
  30.         except:
  31.             pass
  32.     elif type(x) == type(y) and type(x) in (type(()), type([])):
  33.         for i in range(min(len(x), len(y))):
  34.             outcome = fcmp(x[i], y[i])
  35.             if outcome <> 0:
  36.                 return outcome
  37.         return cmp(len(x), len(y))
  38.     return cmp(x, y)
  39.  
  40. TESTFN = '@test' # Filename used for testing
  41. from os import unlink
  42.